<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/default/common-js.jsp"%>
  <%@ include file="/common/default/common-css.jsp"%>
  <title>WHQ | 通用管理模板1</title>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/default/top.jsp" %>
  <!-- top end -->
  
  <!-- left start -->
  <%@include file="/common/default/left.jsp" %>
  <!-- left end-->

  <!-- Main start -->
  <div class="content-wrapper">
  	
  	<section class="container">
	 <div class="row">
	  <div class="col-xs-12 ibox">
		<div class="box-body">
			<form id="searchFrom" class="form-horizontal">
				<input type="hidden" name="doCode" value="dymicSql"/>
				<input type="hidden" name="pageName" value="${sort.objName}-list">
				
				<div class="col-sm-1"><label class="control-label" >ID：</label></div>
				<div class="col-sm-2">
					 <input type="text" class="form-control"  name="${objName}.${objName}Id" value=""/>
				</div>
				<div class="col-sm-1"><label class="control-label" >名称：</label></div>
				<div class="col-sm-2">
					 <input type="text" class="form-control"  name="${objName}.${objName}Name" value=""/>
				</div>
				<button type="button" class="btn btn-success" onclick="getTableData();"><i class="fa fa-edit-circle"></i> 查询</button>&nbsp;
				<button  type="button" class="btn btn-warning" onclick="cleanData('searchFrom');">重置 </button>
			</form>
		</div>
	  </div>
	 </div>
	</section>	
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12 ibox">
            
             <div class="box-header with-border">
              		<div role="toolbar" class="btn-toolbar">
				     <div class="btn-group">
				        <button  onclick="toAdd();" class="btn btn-success" type="button"><i class="fa fa-plus-circle"></i> 增加 </button>
			          </div>
					</div>
             </div>
            
            <!-- /.box-header -->
            <div class="box-body">
              <table id="dataList" class="table table-bordered table-hover" >
                <thead class="bg-success">
                <tr>
                  <th>编号</th>
                  <th>名称</th>
                  <th>类别</th>
                  <th>简介</th>
                  <th>操作</th>
                </tr>
                </thead>
                <tbody id="dataList-body">
                </tbody>
              </table>
              <center>
    	  		<ul id="dataList-page"></ul>
              </center>
            </div>
          </div>
        </div>
      </div>
    </section>
    <!-- Main end -->
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/default/foot.jsp" %>
  <!-- foot start -->
  <!-- right start -->
  <%@include file="/common/default/right.jsp" %>
  <!-- right start -->
  
<div win-title="编辑窗口" class="modal fade" id="my_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
						<h4 class="modal-title">
							<font color="red">${sort.sortName}-添加/修改</font>&nbsp;
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="submitForm">
							<input type="hidden" name="doCode" value="dymicSql">
							<input type="hidden" name="pageName" id="pageName" value="${sort.objName}-list">
							<input type="hidden" name="formName" id="formName" value="addForm">
							<input type="hidden" id="w_${primaryKeyId}" data-name="${primaryKeyId}" name="${sort.objName}.w_${primaryKeyId}"  value="">
							
							<input type="hidden" name="formToken" id="formToken" value="">
					        <div class="box-body" id="submitFormData">
					          <!-- Custom Tabs -->
					          <div class="nav-tabs-custom">
					          <!-- 选项卡请放开 
					            <ul class="nav nav-tabs">
					              <li class="active"><a href="#tab_1" data-toggle="tab">基本信息</a></li>
					              <li><a href="#tab_2" data-toggle="tab">其他信息</a></li>
					            </ul>
					            -->
					            <div class="tab-content">
					              <div class="tab-pane active" id="tab_1">
					              
					              <#list metadatas as mt>
					                <#if mt.dataRestrict!="1">
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >${mt.dataFullName}</label>
					                  <div class="col-sm-8">
					                    <input type="text" id="${mt.dataAttr}" name="${objName}.${mt.dataAttr}" class="form-control" required placeholder="必填项" >
					                  </div>
					                </div>
							        </#if>
							        
								   </#list>
								   
					              </div>					             
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          </div>
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-success pull-left" onclick="cannel('');">取消</button>
				                <button type="button" class="btn btn-danger pull-right" onclick="save('submitForm');">提 交</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>


<div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
						<h4 class="modal-title">
							<font color="red">查看详情</font>&nbsp;
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="viewForm">
					        <div class="box-body">
					          <!-- Custom Tabs -->
					          <div class="nav-tabs-custom">
					          <!-- 选项卡请放开 
					            <ul class="nav nav-tabs">
					              <li class="active"><a href="#tab_1" data-toggle="tab">基本信息</a></li>
					              <li><a href="#tab_2" data-toggle="tab">其他信息</a></li>
					            </ul>
					            -->
					            <div class="tab-content">
					              <div class="tab-pane active" id="tab_1">
					              
					              <#list metadatas as mt>
					                <#if mt.dataRestrict!="1">
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >${mt.dataFullName}</label>
					                  <div class="col-sm-8">
					                  	<span data-name="${mt.dataAttr}"></span>
					                  </div>
					                </div>
							        </#if>
							        
								   </#list>
								   
					              </div>					             
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          </div>
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-success pull-right" onclick="cannel('view');">关闭</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>
 
</body>
	
<script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
			<tr>
				<td><?=rows[i].${objName}No?></td>
				<td><?=rows[i].cateName?></td>
				<td><?=strUtil.doNull(rows[i].cateType,'')?></td>
				<td><?=rows[i].remark?></td>
				<td>
					<button type="button" class="btn btn-success btn-xs" onclick="toLoad('<?=rows[i].${primaryKeyId}?>','view')">查看</button>&nbsp;&nbsp;
					<button type="button" class="btn btn-warning btn-xs" onclick="toLoad('<?=rows[i].${primaryKeyId}?>','edit');">修改</button>&nbsp;&nbsp;
					<button type="button" class="btn btn-danger btn-xs" onclick="toDele('<?=rows[i].${primaryKeyId}?>');">删除</button>
				</td>
			</tr>
		<?}?>
</script>
<script>
var clickMenu = "${sort.objname}-list";
var id,myPage,dataListId,searchFormId,isShowLog,tableSort,tableId;
myPage = 6;
dataListId = "dataList";
searchFormId = "searchFrom";
tableSort = "${sort.objName}";
tableId = "${primaryKeyId}";
isShowLog = true;

$(function () {
	//1、加载分页列表数据
	getTableData();
	//2、控制是否启用token
	//setToken();
	//请在下面补充其他初始化方法（如数据字典、页面加载数据等）
 });
//读取（查询、编辑）数据
function toLoad(id,type){
	var paramLoadData = {"${sort.objName}.w_${primaryKeyId}":id,"modelTypes":"s_"+tableSort};
	loadObj(type,paramLoadData);
}
//反显数据
function showData(type,myData){
	console.log(myData);
	if("view"==type){
		FormUtil.loadView("#", myData);
		$("#my_modal_view").modal("show");
		
	}else if("edit"==type){
		FormUtil.fillData("#submitForm", myData,"id");
		$("#modelTypes").val("u_"+tableSort);
		$("#w_"+tableId).val(myData.${objName}Id);
		$("#formName").val("editForm");
		$("#my_modal").modal("show");
	}
}
</script>
<script src="/js/tools-obj.js"></script>


</html>
